import { stringify } from 'qs';
import request from '@/utils/request';
import { getPageSize } from '@/utils/common';

//1.列表
export async function selectEndorseList(params) { 
  return request(`/server/api/tms/tms-endorsement/selectTmsEndorsementList`, {
    method: 'POST',
    body: params,
  });
}


//1.列表详情 POST /tms-endorsement/viewTmsEndorsementDetails
export async function selectEndorseDetail(params) {
  // params.pageSize = params.pageSize || getPageSize();
  return request(`/server/api/tms/tms-endorsement/viewTmsEndorsementDetails`, {
    method: 'POST',
    body: params,
  });
}



//3、新增、编辑--违章记录 新增 /tms-endorsement/insertTmsEndorsement 
export async function endorseOperate(params) {

  let url = params.id ? 'updateTmsEndorsement' : 'insertTmsEndorsement';
  return request(`/server/api/tms/tms-endorsement/${url}`, {
    method: 'POST',
    body:params,
  });
} 

//4. 删除--违章记录 POST /tms-endorsement/deleteTmsEndorsement
export async function deleteEndorse(params) {
  return request(`/server/api/tms/tms-endorsement/deleteTmsEndorsement`, {
    method: 'POST',
    body: params,
  });
}
//5. 确认--违章记录 POST /tms-endorsement/confirmEndorsement
export async function confirmEndorse(params) {
  return request(`/server/api/tms/tms-endorsement/confirmEndorsement`, {
    method: 'POST',
    body: params,
  });
}
//6. 提交--违章记录 POST /tms-endorsement/commitEndorsement
export async function commitEndorse(params) {
  return request(`/server/api/tms/tms-endorsement/commitEndorsement`, {
    method: 'POST',
    body: params,
  });
}

//7. 导出--违章记录 POST /tms-endorsement/exportEndorsementDetails
export async function exportEndorse(params) {
  params.token = localStorage.getItem('token');
  const url = `/server/api/tms/tms-endorsement/exportEndorsementDetails?${stringify(params)}`;
  window.open(url);
}


